<?Php
#remove the directory path we don't want 
/*by Socheat Ngann at 13/06/2014*/
$request = str_replace("/hetkar/", "", $_SERVER['REQUEST_URI']);
//$request = 'hetkar.com/2014/06/seng-sona-each-domdem.html';
#split the path by '/'
$params = explode("/", $request);
if (!empty($params)) {
    if (@$params[1] == '1') {
        $home = 'http://hetkar.com/1/';
        $request = str_replace('/1/', '/', $request);
        $values = 'http://kikilu9.blogspot.com';
    } elseif (@$params[1] == '2') {
        $home = 'http://hetkar.com/2/';
        $request = str_replace('/2/', '/', $request);
        $values = 'http://loy-news.blogspot.com';
    } elseif (@$params[1] == '3') {
        $home = 'http://hetkar.com/3/';
        $request = str_replace('/3/', '/', $request);
        $values = 'http://khmer-hots.blogspot.com';
    } elseif (@$params[1] == '4') {
        $home = 'http://hetkar.com/4/';
        $request = str_replace('/4/', '/', $request);
        $values = 'http://dotnas.blogspot.com';
    } elseif (@$params[1] == '5') {
        $home = 'http://hetkar.com/5/';
        $request = str_replace('/5/', '/', $request);
        $values = 'http://jompey168.blogspot.com';
    } elseif (@$params[1] == '6') {
        $home = 'http://hetkar.com/6/';
        $request = str_replace('/6/', '/', $request);
        $values = 'http://hetkarnews.blogspot.com';
    } elseif (@$params[1] == '8') {
        $home = 'http://hetkar.com/8/';
        $request = str_replace('/8/', '/', $request);
        $values = 'http://hetkar8.blogspot.com';
    } elseif (@$params[1] == '9') {
        $home = 'http://hetkar.com/9/';
        $request = str_replace('/9/', '/', $request);
        $values = 'http://hetkar9.blogspot.com';
    } elseif (@$params[1] == '10') {
        $home = 'http://hetkar.com/10/';
        $request = str_replace('/10/', '/', $request);
        $values = 'http://hetkar10.blogspot.com';
    } elseif (@$params[1] == '11') {
        $home = 'http://hetkar.com/11/';
        $request = str_replace('/11/', '/', $request);
        $values = 'http://hetkar11.blogspot.com';
    } elseif (@$params[1] == '12') {
        $home = 'http://hetkar.com/12/';
        $request = str_replace('/12/', '/', $request);
        $values = 'http://hetkar12.blogspot.com';
    } elseif (@$params[1] == '13') {
        $home = 'http://hetkar.com/13/';
        $request = str_replace('/13/', '/', $request); // Sren Reach
        $values = 'http://hetkar13.blogspot.com';
    } elseif (@$params[1] == '14') {
        $home = 'http://hetkar.com/14/';
        $request = str_replace('/14/', '/', $request);
        $values = 'http://hetkar14.blogspot.com';
    } elseif (@$params[1] == '15') {
        $home = 'http://hetkar.com/15/';
        $request = str_replace('/15/', '/', $request);
        $values = 'http://hetkar15.blogspot.com'; // Kimhong
    } elseif (@$params[1] == '16') {
        $home = 'http://hetkar.com/16/';
        $request = str_replace('/16/', '/', $request); // Sarai
        $values = 'http://hetkar16.blogspot.com';
    } elseif (@$params[1] == '17') {
        $home = 'http://hetkar.com/17/';
        $request = str_replace('/17/', '/', $request); // Ting Kech
        $values = 'http://hetkar17.blogspot.com';
    } elseif (@$params[1] == '18') {
        $home = 'http://hetkar.com/18/';
        $request = str_replace('/18/', '/', $request); // somphos Leav
        $values = 'http://hetkar18.blogspot.com';
    } elseif (@$params[1] == '19') {
        $home = 'http://hetkar.com/19/';
        $request = str_replace('/19/', '/', $request); // hour kim vou Leav
        $values = 'http://hetkar19.blogspot.com';
    } elseif (@$params[1] == '20') {
        $home = 'http://hetkar.com/20/';
        $request = str_replace('/20/', '/', $request); // pheak dey sot (not ready)
        $values = 'http://hetkar20.blogspot.com';
    } elseif (@$params[1] == '21') {
        $home = 'http://hetkar.com/21/';
        $request = str_replace('/21/', '/', $request); // chamna nom
        $values = 'http://hetkar21.blogspot.com';
    } elseif (@$params[1] == '22') {
        $home = 'http://hetkar.com/22/';
        $request = str_replace('/22/', '/', $request); // Tewin
        $values = 'http://hetkar22.blogspot.com';
    } elseif (@$params[1] == '23') {
        $home = 'http://hetkar.com/23/';
        $request = str_replace('/23/', '/', $request); // Bun Sea
        $values = 'http://hetkar23.blogspot.com';
    } elseif (@$params[1] == '25') {
        $home = 'http://hetkar.com/25/';
        $request = str_replace('/25/', '/', $request); // Pheng nephew
        $values = 'http://hetkar25.blogspot.com';
    } elseif (@$params[1] == '26') {
        $home = 'http://hetkar.com/26/';
        $request = str_replace('/26/', '/', $request); // Vathana
        $values = 'http://hetkar26.blogspot.com';
    } elseif (@$params[1] == '27') {
        $home = 'http://hetkar.com/27/';
        $request = str_replace('/27/', '/', $request); // Sanith
        $values = 'http://hetkar27.blogspot.com';
    } else {
        $values = 'http://mhetkar.blogspot.com';
    }
} else {
    $values = '';
}

/* =======for other blog ====== */
if (!empty($params[1]) && !empty($params[2])) {
    $urls = str_replace('hetkar.com', '', $request);
    $values = $values . '/' . $urls;
} elseif (!empty($params[1]) && empty($params[2])) {
    if (strlen(@$params[1]) == 1) {
        $values = $values;
    } else {
        $urls = str_replace('hetkar.com', '', $request);
        $values = $values . '/' . $urls;
    }
} else {
    /* ======= for main blog ====== */
    if (!empty($params[1])) {
        $urls = str_replace('hetkar.com/', '', $request);
        $values = $values . '/' . $urls;
    } else {
        $values = 'http://mhetkar.blogspot.com';
    }
}

function replace_name($param) {
    if (preg_match('/news.hetkar.com/', $param)) {
        $blog = 'news.hetkar.com';
        $to = 'hetkar.com';
    } elseif (preg_match('/kikilu9.blogspot.com/', $param)) {
        $blog = 'kikilu9.blogspot.com/';
        $to = 'hetkar.com/1/';
    } elseif (preg_match('/loy-news.blogspot.com/', $param)) {
        $blog = 'loy-news.blogspot.com/';
        $to = 'hetkar.com/2/';
    } elseif (preg_match('/khmer-hots.blogspot.com/', $param)) {
        $blog = 'khmer-hots.blogspot.com/';
        $to = 'hetkar.com/3/';
    } elseif (preg_match('/dotnas.blogspot.com/', $param)) {
        $blog = 'dotnas.blogspot.com/';
        $to = 'hetkar.com/4/';
    }
    $link = str_replace($blog, $to, $param);
    return $link;
}
?>
<!DOCTYPE HTML>
<html>
    <head>
        <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
        <meta name="author" content="www.hetkar.com" />
        <link href='http://hetkar.com/favicon.ico' rel='icon' type='image/x-icon'/>
        <?php
        /* ==========All Post for single post=========== */
        if (!empty($params)) {
            if (@$params[1] == 'search' || strlen(@$params[1]) == 4 || @$params[2] == 'search' || strlen(@$params[2]) == 4) {
                include 'simple_html_dom.php';
                $html = file_get_html($values);
                $title = $html->find('title', 0)->innertext;
                $image = $html->find('.post-single-body .oneleft img', 0)->src;
                echo "<link href='$image' rel='image_src'/>";
                echo '<meta property="og:image" content="' . $image . '"/>';
                $breadcrumb = $html->find('.post-single-body .oneleft .tags', 0)->innertext;
                $breadcrumb = replace_name($breadcrumb);
                $breadcrumb = str_replace(',', '<span class="brn_arrow">&raquo;</span>', $breadcrumb);
            }
        }
        /* ==========end All Post for single post=========== */
        ?>
        <title><?php echo (!empty($title) ? $title . ' - ' : ''); ?> Hetkar.com, Khmer News, Cambodia News, Hot news</title>
        <meta content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0' name='viewport'/>
        <link href='http://fonts.googleapis.com/css?family=Hanuman' rel='stylesheet' type='text/css'>
        <meta name="alexaVerifyID" content="mO8BZ-kFCLlIncwzk1DqtSmmZ50"/>
        <meta name="google-site-verification" content="PXV2sawavvSMBDrE0ZHVWQwPl98Ub6oMSWLG4LY1DK8" />
        <meta name="msvalidate.01" content="FE1EF30C44018A489D700CC6F575BCB8" />
        <link rel="alternate" type="application/atom+xml" title="Hetkar.com: Daily News, Khmer News and Global news - Atom" href="http://hetkar.com/rss.php" />
        <meta name="keywords" content="<?php echo (!empty($title) ? $title . ' - ' : ''); ?> Accessories, Apple, Computer,    Computer help,    Daily News,    Dialy News,    Douch Sophea,    Economic,    Entertainment,    Entertainment News,    General Knowedge,,    Global news,,    good Idea you shoud know,,    Health,,    Help,,    Hollywood Stars,    HTC,    International News,,    Internet,    Khmer Actress,    Khmer News,    Khmer News in Cambodia,    Khmer Star,    Korean Stars,    Latest,    LG,    Marketing,    Mobile,    News,    Nokia,    Politic,    Samsung,,    Smartphone,,    Social News,    Social News Daily News,   Social News Daily News,    Songs,    Sonny,    Sports,    Sruol ???,    Star News,    Tablets,    Technology,    Technology News,    Videos,    Videos Star,Popul" />
        <meta name="description" content="<?php echo (!empty($title) ? $title . ' - ' : ''); ?> Accessories, Apple, Computer,    Computer help,    Daily News,    Dialy News,    Douch Sophea,    Economic,    Entertainment,    Entertainment News,    General Knowedge,,    Global news,,    good Idea you shoud know,,    Health,,    Help,,    Hollywood Stars,    HTC,    International News,,    Internet,    Khmer Actress,    Khmer News,    Khmer News in Cambodia,    Khmer Star,    Korean Stars,    Latest,    LG,    Marketing,    Mobile,    News,    Nokia,    Politic,    Samsung,,    Smartphone,,    Social News,    Social News Daily News,   Social News Daily News,    Songs,    Sonny,    Sports,    Sruol ???,    Star News,    Tablets,    Technology,    Technology News,    Videos,    Videos Star,Popul" />
        <script language="javascript" type="text/javascript">
            var win = null;
            function NewWindow(mypage, myname, w, h, scroll, pos) {
                if (pos == "random") {
                    LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100;
                    TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100;
                }
                if (pos == "center") {
                    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100;
                    TopPosition = (screen.height) ? (screen.height - h) / 2 : 100;
                }
                else if ((pos != "center" && pos != "random") || pos == null) {
                    LeftPosition = 0;
                    TopPosition = 20
                }
                settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=yes,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
                win = window.open(mypage, myname, settings);
            }
            // -->
        </script>
        <script type="text/javascript">

                <!--
		
            //Disable right click script III- By Renigade (renigade@mediaone.net)
            //For full source code, visit http://www.dynamicdrive.com

            var message = "Function Disabled!";
            ///////////////////////////////////
            function clickIE() {
                if (document.all) {
                    (message);
                    return false;
                }
            }
            function clickNS(e) {
                if
                        (document.layers || (document.getElementById && !document.all)) {
                    if (e.which == 2 || e.which == 3) {
                        (message);
                        return false;
                    }
                }
            }
            if (document.layers)
            {
                document.captureEvents(Event.MOUSEDOWN);
                document.onmousedown = clickNS;
            }
            else {
                document.onmouseup = clickNS;
                document.oncontextmenu = clickIE;
            }

            document.oncontextmenu = new Function("return false")
            // -->
            MediaObject.init({'flash': "9,0,124,0", 'windowmedia': "5,1,52,701", 'quicktime': "6,0,2,0", 'realmedia': "7,0,0,0", 'shockwave': "8,5,1,0"});
            jQuery(document).ready(function() {
                jceutilities({'popup': {'legacy': 0, 'resize': 1, 'icons': 1, 'overlay': 1, 'overlayopacity': 0.8, 'overlaycolor': "#000000", 'fadespeed': 500, 'scalespeed': 500, 'width': 640, 'height': 480, 'hideobjects': 1, 'scrollpopup': 1, 'theme': "standard", 'themecustom': "", 'themepath': "plugins/system/jceutilities/themes"}, 'tootlip': {'classname': "tooltip", 'opacity': 1, 'speed': 150, 'position': "br", 'offsets': "{'x': 16, 'y': 16}"}, 'imgpath': "plugins/system/jceutilities/img", 'pngfix': 1, 'wmode': 0});
            });
        </script>
        <link type='text/css' rel='stylesheet' href='http://hetkar.com/css/stylesheet.css' />
    </head>
    <body>
        <?php
        include 'header.php';
        $url = (!empty($values)) ? $values : 'http://mhetkar.blogspot.com';
        ?>

        <iframe allowtransparency='true' class='templatedemo' frameborder='0' id='rf' scrolling='auto' src='<?php echo $url; ?>'></iframe>
        <!-- Histats.com  START  (standard)-->
        <script type="text/javascript">document.write(unescape("%3Cscript src=%27http://s10.histats.com/js15.js%27 type=%27text/javascript%27%3E%3C/script%3E"));</script>
        <div  class="onlinepage">
            <div style="height:15px;overflow:hidden;text-align: center"><img src="http://whos.amung.us/swidget/cf0500ffd7d7.png" title="Click to see how many people are online" border="0" height="15" width="80"/></div>
            <iframe src="http://hetkar.com/online.html" frameborder="0" height="48" width="110" scrolling="no"></iframe>
        </div>
        <script>
            (function(i, s, o, g, r, a, m) {
                i['GoogleAnalyticsObject'] = r;
                i[r] = i[r] || function() {
                    (i[r].q = i[r].q || []).push(arguments)
                }, i[r].l = 1 * new Date();
                a = s.createElement(o),
                        m = s.getElementsByTagName(o)[0];
                a.async = 1;
                a.src = g;
                m.parentNode.insertBefore(a, m)
            })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

            ga('create', 'UA-39179868-4', 'hetkar.com');
            ga('send', 'pageview');

        </script>
    </body>
</html>